Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
¿Qué dosis significa "window.scrollY> 0"?
window.addEventListener("scroll",()=>{
const header = document.querySelector("header");
header.classList.toggle("sticky", window.scrollY > 0);
})

Sé sobre el método .toggle() pero no tan claramente. ¿Podría alguien explicar acerca de toggle() y window.scrollY?

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Desplácese hacia abajo. La propiedad scrollY de la interfaz de la ventana devuelve el número de píxeles que el documento se desplaza verticalmente actualmente.

 window.addEventListener("scroll", (event) => {
 document.querySelector("h1").textContent = this.scrollY;
 document.querySelector("h2").textContent = ("sticky", window.scrollY > 0);
})
 body {
 width: 100vw;
 height: 400vh;
}

h1 {
 position: fixed;
 top: 0;
}

h2 {
 position: fixed;
 top: 20%;
}
 <h1>0</h1>
<h2></h2>

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!